using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WinSAG
{
    public partial class WSF_PropertiesDialog : Form
    {
        object internalObj = null;

        internal WSF_PropertiesDialog()
        {
            InitializeComponent();        
        }

        internal void setPropertiesObject(object pp)
        {
            if (!(pp is IGridProperties ))
            {
                throw new ApplicationException(WSU_Literals.MSG_EXCEPTION_INTERFACE_ERROR);
            }
            propertyGrid.SelectedObject = pp;
            internalObj = pp;
            this.Text = (pp as IGridProperties).getObjectName();
        }

        private void btnProperties_Cancel_Click(object sender, EventArgs e)
        {
            try
            {
                (internalObj as IGridProperties).setDirty(false);
            }
            catch (Exception e1)
            {
                // TODO: Handle the exception?
            }
            Close();            
        }

        private void btnProperties_Ok_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            try
            {
                (internalObj as IGridProperties).setDirty(true);
            }
            catch (Exception e1)
            {
                // TODO: Handle the exception?
            }                        
        }        
    }
}